class Solution2 {
    static class TreeNode {
        char val;
        Demo.TreeNode left;
        Demo.TreeNode right;
        TreeNode(char val){
            this.val = val;
        }
    }
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null&&q!=null||p!=null&&q==null){
            return false;
        }
        if(q==null&&q==null){
            return true;
        }
        if(p.val!=q.val){
            return false;
        }
        //return isSameTree(p.left,q.left)&&isSameTree(p.right,q.right);
        return false;
    }
}